package viethp.mtrade.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;

public class ASplashScreen extends Activity{
	
	protected int _splashTime = 500; 

	private Thread splashTread;
	
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.a_splash);
		
		showSplash();
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {
	    if (event.getAction() == MotionEvent.ACTION_DOWN) {
	    	synchronized(splashTread){
	    		splashTread.notifyAll();
	    	}
	    }
	    return true;
	}

	public void showSplash(){
//	    final ASplashScreen sPlashScreen = this; 

	    // thread for displaying the SplashScreen
	    splashTread = new Thread() {
	        @Override
	        public void run() {
	            try {
	            	synchronized(this){

	            		//wait 5 sec
	            		wait(_splashTime);
	            	}

	            } catch(InterruptedException e) {}
	            finally {
	            	
	            	Intent i = new Intent(getBaseContext(),ALogin.class);
	                startActivity(i);
	                finish();
	                
	                ASplashScreen.this.overridePendingTransition(R.anim.appear,
							R.anim.disappear);
	                
	            }
	        }
	    };

	    splashTread.start();
	}
}
